﻿<UserControl x:Class="MoleculeViewer.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:graph="clr-namespace:SpringGraph;assembly=SpringGraph"
    xmlns:graphControls="clr-namespace:SpringGraph.Controls;assembly=SpringGraph"
    xmlns:templateSelectors="clr-namespace:MoleculeViewer.TemplateSelectors"
    mc:Ignorable="d" d:DesignHeight="600" d:DesignWidth="800" >
    
    <UserControl.Resources>
        <ControlTemplate x:Key="CMoleculeTemplate" >
            <Grid>
                <Ellipse Height="30" Width="30" >
                	<Ellipse.Fill>
                		<RadialGradientBrush>
                			<GradientStop Color="#FF6A6868"/>
                			<GradientStop Color="#FFB4AEAE" Offset="1"/>
                		</RadialGradientBrush>
                	</Ellipse.Fill>
                </Ellipse>
                
                <TextBlock Text="{Binding ElementType}" HorizontalAlignment="Center" VerticalAlignment="Center" />
            </Grid>
        </ControlTemplate>

        <ControlTemplate x:Key="NMoleculeTemplate" >
            <Grid>
                <Ellipse  Height="30" Width="30" >
                	<Ellipse.Fill>
                		<RadialGradientBrush>
                			<GradientStop Color="#FF075AE2" Offset="1"/>
                			<GradientStop Color="#FFE3E9F3"/>
                		</RadialGradientBrush>
                	</Ellipse.Fill>
                </Ellipse>

                <TextBlock Text="{Binding ElementType}" HorizontalAlignment="Center" VerticalAlignment="Center" />
            </Grid>
        </ControlTemplate>

        <ControlTemplate x:Key="OMoleculeTemplate" >
            <Grid>
                <Ellipse  Height="30" Width="30" >
                	<Ellipse.Fill>
                		<RadialGradientBrush>
                			<GradientStop Color="#FFFDF7F7" Offset="0"/>
                			<GradientStop Color="#FFFF0808" Offset="1"/>
                		</RadialGradientBrush>
                	</Ellipse.Fill>
                </Ellipse>

                <TextBlock Text="{Binding ElementType}" HorizontalAlignment="Center" VerticalAlignment="Center" />
            </Grid>
        </ControlTemplate>

        <ControlTemplate x:Key="HMoleculeTemplate" >
            <Grid>
                <Ellipse  Height="30" Width="30" >
                	<Ellipse.Fill>
                		<RadialGradientBrush>
                			<GradientStop Color="#FFB8B8B8" Offset="0"/>
                			<GradientStop Color="White" Offset="1"/>
                		</RadialGradientBrush>
                	</Ellipse.Fill>
                </Ellipse>

                <TextBlock Text="{Binding ElementType}" HorizontalAlignment="Center" VerticalAlignment="Center" />
            </Grid>
        </ControlTemplate>


        <templateSelectors:MoleculeTemplateSelector x:Key="MoleculeTemplateSelector"
                                               CMoleculeTemplate="{StaticResource CMoleculeTemplate}"
                                               NMoleculeTemplate="{StaticResource NMoleculeTemplate}"
                                               OMoleculeTemplate="{StaticResource OMoleculeTemplate}"
                                               HMoleculeTemplate="{StaticResource HMoleculeTemplate}" />
    </UserControl.Resources>

    <Grid x:Name="LayoutRoot" Background="#FFB8CDE0" >

        <graph:SpringGraph x:Name="Graph" NodeTemplateSelector="{StaticResource MoleculeTemplateSelector}" >

            <graphControls:NavControl 
                  HorizontalAlignment="Left" VerticalAlignment="Top" 
                  Margin="10,10,0,0" RenderTransformOrigin="0.5,0.5" >
                <graphControls:NavControl.RenderTransform>
                    <TransformGroup>
                        <ScaleTransform ScaleX="0.8" ScaleY="0.8"/>
                        <SkewTransform/>
                        <RotateTransform/>
                        <TranslateTransform/>
                    </TransformGroup>
                </graphControls:NavControl.RenderTransform>
            </graphControls:NavControl>

        </graph:SpringGraph>

        <ListBox x:Name="ListBoxMolecules" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="20, 250, 0, 0" MinWidth="100" SelectionChanged="ListBoxMolecules_SelectionChanged" />
    </Grid>
</UserControl>
